﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using IDb;
using Serialization;
using DataDeal;
using Model;

namespace OMSWeb.service.Systems
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ParameterHandler : IHttpHandler
    {
        HttpContext Context;
        DictionaryDAL _dal;
        string json = "";
        ISerializer jsonconvert = SerializerFactory.GetSerializer(SerializerStyle.Json);

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            try
            {
                if (context.Request.Params["Action"] == "get")
                {
                    _dal = new DictionaryDAL();
                    IList<Dictionary> list = _dal.GetQueryByTypeId("Value");
                    string result = jsonconvert.Serialize<IList<Dictionary>>(list);
                    json = "{Rows:" + result + ",Total:" + list.Count + "}";
                    context.Response.Write(json);

                }
            }
            catch (Exception err)
            {
            }
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
